@include('home.public.header')
<style>
    input {
        width: 100%;
        border: none;
        background: transparent;
        padding-left: 0 !important;
    }
</style>
<!-- HEADING-BANNER START -->
<div class="heading-banner-area overlay-bg">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="heading-banner">
                    <div class="heading-banner-title">
                        <h2>个人中心</h2>
                    </div>
                    <div class="breadcumbs pb-15">
                        <ul>
                            <li><a href="/">Home</a></li>
                            <li>个人中心</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- HEADING-BANNER END -->
<!-- MY-ACCOUNT-AREA START -->
<div class="my-account-area  pt-80 pb-80">
    <div class="container">
        <div class="my-account">
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="panel-group" id="accordion">
                        <div class="panel">
                            <div class="my-account-menu" >
                                <a  data-toggle="collapse" data-parent="#accordion" href="#my-info" >
                                    我的资料
                                </a>
                            </div>
                            <div id="my-info" class="panel-collapse collapse in" >
                                <div class="panel-body">
                                    <div class="billing-details shop-cart-table">
                                        <div class="form_style" ><input type="text" id="user_name" value="" placeholder="用户名称"></div>
                                        <div class="form_style" ><input type="email" id="user_email" value="" placeholder="用户邮箱"></div>
                                        <div class="form_style" ><input type="tel" id="user_tel" value="" placeholder="用户电话"></div>
                                        <div class="form_style" ><input type="text" id="user_address" value="" placeholder="用户地址"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                    </div>
                    <button type="submit" data-text="apply coupon" class="button-one submit-button mt-15" id="user_info">修改信息</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- MY-ACCOUNT-CART-AREA END -->
@include('home.public.footer2')

<script !src="">
    var user_name = $('#user_name').val();
    var user_email = $('#user_email').val();
    var user_tel = $('#user_tel').val();
    var user_address = $('#user_address').val();

    var data = {}
    data['user_name'] = user_name;
    data['user_email'] = user_email;
    data['user_tel'] = user_tel;
    data['user_address'] = user_address;

    $.ajax({
        type: 'post',
        url: '/user_info',
        data: data,
        dataType: "json",
        success:function(res){
            // console.log(res)
            if(res == 2) {
                alert("您还未登录，请登录");
                location.href = "/login"
            }else {
                $('#user_name').val(res.user_name)
                $('#user_email').val(res.user_email)
                $('#user_tel').val(res.user_tel)
                $('#user_address').val(res.user_address);
            }
        }
    });

    $(document).on('click','#user_info',function () {
        var user_name = $('#user_name').val();
        var user_email = $('#user_email').val();
        var user_tel = $('#user_tel').val();
        var user_address = $('#user_address').val();

        var data = {}
        data['user_name'] = user_name;
        data['user_email'] = user_email;
        data['user_tel'] = user_tel;
        data['user_address'] = user_address;
        $.ajax({
            type: 'post',
            url: '/user_info2',
            data: data,
            dataType: "json",
            success:function(res){
                // console.log(res)
                if(res == 2) {
                    alert("您还未登录，请登录");
                    location.href = "/login"
                }else if(res == 3) {
                    alert("修改失败，请重新修改");
                } else {
                    $('#user_name').val(res.user_name)
                    $('#user_email').val(res.user_email)
                    $('#user_tel').val(res.user_tel)
                    $('#user_address').val(res.user_address);
                    alert('修改成功');
                }
            }
        });
    })

</script>